﻿$(document.body).ready(function () {
    var searchString = $('input[name=searchString]').val();
    setSort()
    $(".name-col").click(function () {
        if ($('input[name=orderNum]').val() == "0") {
            $('input[name=orderNum]').val("1");
        } else if ($('input[name=orderNum]').val() == "1") {
            $('input[name=orderNum]').val("0");
        }
        setSort();
        $('input[name=searchString]').val(searchString);
        $(".filter").submit()
    });
    $(".delete-col").on("click", ".icon-remove", function () {
        var row = $(this).parent().parent()
        var id = row.attr("id")
        doAjax("Admin", "DeleteRoute", { id: id }, function () {
            row.remove()
        }, function () {
            alert("Ошибка")
        });
    });
});
function setSort() {
    if ($('input[name=orderNum]').val() == "0") {
        $(".icon-chevron-up").removeClass("hidden");
        $(".icon-chevron-down").addClass("hidden");
    }
    if ($('input[name=orderNum]').val() == "1") {
        $(".icon-chevron-down").removeClass("hidden")
        $(".icon-chevron-up").addClass("hidden")
    }
}